﻿
@model Model.News.E_tb_News
@{
    ViewBag.Title = "NewsList";
}

<!DOCTYPE html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title>首页图片列表</title>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/default/easyui.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/themes/icon.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/jquery-easyui/demo.css")'/>
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/uploader/uploadify.css")' />
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/Validform/style.css")'  />
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Scripts/Validform/style.css")'  />
    <link rel="stylesheet" type="text/css" href='@Url.Content("~/Content/XINDECSS/MainStyle.css")'/>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-1.8.2.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/jquery.easyui.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery-easyui/locale/easyui-lang-zh_CN.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/jquery.uploadify.min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/uploader/swfobject.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/MicrosoftMvcAjax.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/Validform/Validform_v5.3.2_min.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")'></script>
    <script type="text/javascript" src='@Url.Content("~/Scripts/kindeditor/kindeditor-min.js")'></script>

    @*<script src="../../Scripts/jquery-1.8.2.js" type="text/javascript"></script>*@
    <script type="text/javascript">
        $(document).ready(function () {
            $('#dgtable').datagrid({
                url: "/News/GetList?pageNumber=1&pageSize=8",
                pagination: true, //分页控件  
                singleSelect: true, //是否单选
                rownumbers: true,
                columns: [[
//                    { field: 'NewID', title: '编号', align: 'center' },
                    { field: 'Title', title: '公告标题', align: 'center'},
                    { field: 'TypeName', title: '公告类型', align: 'center'},
                    { field: 'UpdateTime', title: '更新时间', align: 'center' },
                    {
                        field: 'Edit', title: '编辑', align: 'center',
                        formatter: function (value, row, index) {
                            return "@if (Convert.ToBoolean(ViewData["acc2d249"]))
                                    {<a href='javascript:void(0)' onclick='Edit(" + row.NewID + ")' ><img width='18px' height='18' alt='修改' src='/Content/Images/xiugai.png' /></a>}";
                        }
                    },
                    {
                        field: 'Delete', title: '删除', align: 'center',
                        formatter: function (value, row, index) {
                            var linkstr = "@if (Convert.ToBoolean(ViewData["7338f4b9"]))
                                           {<a href=\"javascript:void(0)\" onclick=\"Delete(" + row.NewID + ")\" ><img width='18px' height='18' alt=\"删除\" src=\"/Content/Images/shanchu.png\" /></a>}";
                            return linkstr;
                        }
                    }
                ]],
                onLoadSuccess: function (data) {
                    if (!data.rows) {
                        var body = $(this).data().datagrid.dc.body2;
                        body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 25px; text-align: center;">没有数据</td></tr>');
                    }
                }
            });
            var p = $('#dgtable').datagrid('getPager');
            $(p).pagination({
                pageSize: 8, //每页显示的记录条数，默认为10  
                pageList: [8, 10, 15, 20], //可以设置每页记录条数的列表  
                onSelectPage: function (pageNumber, pageSize) {
                    $('#dgtable').datagrid('options').url = "/News/GetList?pageNumber=" + pageNumber + "&pageSize=" + pageSize;
                    $("#dgtable").datagrid("reload");
                }
            });

            $('#EditForms').dialog('close');
        });

        //删除
        function Delete(InfoID) {
            if (confirm("确定要删除数据吗？")) {
                $.getJSON("/News/Delete/" + InfoID,
                function (data) {
                    alert(data);
                    if (data == "删除成功！") {
                        $('#dgtable').datagrid('reload');
                    }
                });
            }
        }

        //查询
        function click_Search() {
            var txts = $("#txt_Search").val();
            var NewTypeID=$("#Search_NewTypeID").val();
            var StartTime=$("#txt_StartTime").val();
            var EndTime=$("#txt_EndTime").val();
            $('#dgtable').datagrid('options').url = "/News/GetList?pageNumber=1&pageSize=8&StrSearch=" + txts+"&NewTypeID="+NewTypeID+"&StartTime="+StartTime+"&EndTime="+EndTime;;
            $("#dgtable").datagrid("reload");
        }
    </script>

    <!--编辑-->
    <script type="text/javascript">
        //添加
        function Add() {
            $("#HidEditType").val("Add");
            $("#HidNewID").val("");
            $("#txt_Title").val("");
            $("#drop_NewTypeID").val("");
            window.editor.html("");
            $('#EditForms').dialog('open');
//            $('#EditForms').window({ href: '/News/NewsEdit?EditType=Add' });
//            $('#EditForms').window('refresh');
//            $('#EditForms').window('open');
        }

        //弹出编辑页
        function Edit(InfoID) {
            $.get("/News/NewsEdit?EditType=Edit&InfoID=" + InfoID, function (NewsInfo) {
                $("#HidEditType").val(NewsInfo.EditType);
                $("#HidNewID").val(NewsInfo.NewID);
                $("#txt_Title").val(NewsInfo.Title);
                $("#drop_NewTypeID").val(NewsInfo.NewTypeID);
                window.editor.html(NewsInfo.Contents);
                $('#EditForms').dialog('open');
            });
//            $('#EditForms').window({ href: '/News/NewsEdit?EditType=Edit&InfoID=' + InfoID });
//            $('#EditForms').window('refresh');
//            $('#EditForms').window('open');
        }

        //关闭弹出层
        function Close() {
            //$('#EditForms').window('close');
            $('#EditForms').dialog('close');
        }

        //保存提示
        function handle(e) {
            if (e == "1") {
                alert("保存成功！");
                $('#EditForms').window('close');
                $('#dgtable').datagrid('reload');
            } else {
                alert("保存失败！");
            }
        }
        function failed(e) {
            alert("保存失败！");
        }
    </script>

        <!--绑定编辑器-->
    <script type="text/javascript">
        KindEditor.ready(function (K) {
            var options = {
                uploadJson: '/Scripts/kindeditor/asp.net/upload_json.ashx',
                fileManagerJson: '/Scripts/kindeditor/asp.net/file_manager_json.ashx',
                afterBlur: function () { editor.sync(); },
                allowFileManager: true
            };
            window.editor = K.create('#txt_Contents', options);
        });
    </script>
</head>
<body>
    <!--标题-->
    <table cellpadding="0" cellspacing="0" width="100%" class="HeadTitle">
        <tr>
            <td>当前位置：公告管理<img style="text-align:center;vertical-align:middle;height:10px" src='@Url.Content("~/Content/Images/位置.png")' />公告列表 </td>
        </tr>
    </table>

    <!--数据列表-->
    <div class="divList">
        <table cellpadding="0" cellspacing="0" width="100%" class="WhereTable">
            <tr>
                <td align="right"style="width:70px;">公告类别：</td>
                <td align="left" style="width:100px;" >@Html.DropDownListFor(m => m.NewTypeID, ViewData["SearchNewsTypeList"] as SelectList, new { @id = "Search_NewTypeID" })</td>
                <td align="right"style="width:70px;">公告标题：</td>
                <td align="left" style="width:160px;" ><input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_Search" /></td>
                <td align="right"style="width:70px;">发布时间：</td>
                <td align="left" style="width:160px;" ><input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_StartTime" onclick="WdatePicker()" /></td>
                <td align="right"style="width:30px;">至：</td>
                <td align="left" style="width:160px;" ><input style="border: 1px solid #3496d6;" width="150px" type="text" id="txt_EndTime" onclick="WdatePicker()" /></td>
                <td width="67px"><a href="javascript:void(0)" onclick="click_Search()"><img height="20" src="/Content/Images/chaxun.png" /></a></td>
                <td align="left" width="67px">
                @if (Convert.ToBoolean(ViewData["2df3fdf4"]))
                {<a href="javascript:void(0)" onclick="Add()"><img src="/Content/Images/xinzeng.png" height="20" /></a> }
                </td>
                <td align="right"></td>
            </tr>
        </table>
        <table cellpadding="0" cellspacing="0" class="biaoge easyui-datagrid" id="dgtable" width="100%">

        </table>
    </div>

   <!--编辑页-->
   <div id="EditForms2" class="easyui-window" title="公告信息"  data-options="iconCls:'icon-save',modal:true,closed:true,minimizable:false">  
        
   </div>

   <div id="EditForms" class="easyui-dialog" title="公告信息" data-options="iconCls:'icon-save'" style="width:800px;height:400px;">
        @using (Ajax.BeginForm("Save", "News", new AjaxOptions { HttpMethod = "Post", OnSuccess = "handle", OnFailure = "failed" }, new { @id = "frmUpdate" }))
        {
            @Html.HiddenFor(m => m.NewID, new { @id = "HidNewID" })
            @Html.HiddenFor(m => m.EditType, new { @id = "HidEditType" })
            <table border="0" cellpadding="0" cellspacing="0" width="98%" class="DialogTable">
                <tr>
                    <td width="70px" align="right">公告标题：</td>
                    <td align="left" style="width:260px;">@Html.TextBoxFor(m => m.Title, new { @style = "width:99%;", @id = "txt_Title" })</td>
                    <td width="70px" align="right">公告类型：</td>
                    <td align="left">@Html.DropDownListFor(m => m.NewTypeID, ViewData["NewsTypeList"] as SelectList, new { @id = "drop_NewTypeID" })</td>
                </tr>
                <tr>
                    <td valign="top" align="right">内容：</td>
                    <td colspan="3">
                         @Html.TextAreaFor(m => m.Contents, new { @style = "height:280px;width:99%;", @id = "txt_Contents" })
                    </td>
                </tr>
                <tr>
                    <td colspan="4" align="center">
                        <a href="javascript:void(0)" onclick="$('#frmUpdate').submit()"><img src="~/Content/Images/baocun.png" height="20px" /></a>
                        <a href="javascript:void(0)" onclick="Close()"><img src="~/Content/Images/quxiao.png" height="20px" /></a>
                    </td>
                </tr>
            </table>
        }
   </div>

</body>
